﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CommissionManager.aspx.cs"
    Inherits="LotteryVote.CommissionManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JS/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="JS/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
    <link href="UI/start/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
    <link href="Style/comm.css" rel="stylesheet" type="text/css" />
    <link href="Style/Commission.css" rel="stylesheet" type="text/css" />
    <link href="Style/TableBaseStyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function parseCommission() {
            var txtboxs = $("#commTb input");
            var isFirst = true;
            var content = "[";
            $(txtboxs).each(function (i, ele) {
                if (ele.id == "comm") {
                    if (isFirst)
                        isFirst = false;
                    else
                        content += ",";
                    ele = $(ele);
                    var item = "{" + "\"Commission\":" + ele.val() + ",\"CompanyTypeId\":" + ele.attr("comtype") + ",\"GameTypeId\":" + ele.attr("gametype");
                    var odds;
                    $(txtboxs).each(function (k, o) {
                        if (o.id == "odds") {
                            o = $(o);
                            var comtype = o.attr("comtype");
                            var gametype = o.attr("gametype");
                            if (ele.attr("comtype") == comtype && gametype == ele.attr("gametype")) {
                                odds = o.val();
                                return;
                            }
                        }
                    });
                    item += ",\"Odds\":" + odds + "}";
                    content += item;
                }
            });
            content += "]";
            $("#<%=hd_commission.ClientID %>").val(content);
            //document.write(content);
            //return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" onsubmit="parseCommission()">
    <h3>
        <%=GetGlobalResourceObject("Resource","New") %></h3>
    <div id="searchBar">
        LotterySpecies:<asp:DropDownList ID="ddl_lotterySpecies" runat="server">
        </asp:DropDownList>
        <%=GetGlobalResourceObject("Resource","GroupName")%>:<asp:TextBox ID="txt_groupName"
            runat="server"></asp:TextBox></div>
    <br />
    <table id="commTb" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
                <td rowspan="2">
                    <%=GetGlobalResourceObject("Resource","GameType") %>
                </td>
                <%foreach (var comType in CompanyTypeList)
                  { %>
                <td colspan="2">
                    <%=comType.Description %>
                </td>
                <%} %>
            </tr>
            <tr>
                <%for (int i = 0; i < CompanyTypeList.Count; i++)
                  { %>
                <td>
                    <%=GetGlobalResourceObject("Resource","Comm") %>
                </td>
                <td>
                    <%=GetGlobalResourceObject("Resource","Odds") %>
                </td>
                <%} %>
            </tr>
        </thead>
        <%foreach (var gameType in GameTypeList)
          { %>
        <tr>
            <td>
                <%=gameType.Description %>
            </td>
            <%foreach (var comType in CompanyTypeList)
              { %>
            <td>
                <input id="comm" gametype='<%=gameType.Value %>' comtype='<%=comType.Value %>' type="text"
                    style="width: 60px" />
            </td>
            <td>
                <input id="odds" gametype='<%=gameType.Value %>' comtype='<%=comType.Value %>' type="text"
                    style="width: 60px" />
            </td>
            <%} %>
        </tr>
        <%} %>
    </table>
    <asp:HiddenField ID="hd_commission" runat="server" />
    <asp:Button ID="btn_AddGroup" runat="server" Text="<%$Resources:Resource,Add %>"
        OnClick="btn_AddGroup_Click" />
    </form>
</body>
</html>
